load("@fbcode_macros//build_defs/lib:rust_oss.bzl", "rust_oss")
load("@fbsource//tools/build_defs:rust_library.bzl", "rust_library")

oncall("scm_server_infra")

rust_library(
    name = "repo_factory",
    srcs = glob(["src/**/*.rs"]),
    named_deps = ({} if rust_oss.is_oss_build() else {
        "MononokeRepoFactoryStats_ods3_types": "//eden/mononoke/facebook/ods3_schemas:MononokeRepoFactoryStats_ods3-rust",
    }),
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:parking_lot",
        "fbsource//third-party/rust:thiserror",
        "fbsource//third-party/rust:tokio",
        "fbsource//third-party/rust:tracing",
        "//common/rust/shed/async_once_cell:async_once_cell",
        "//common/rust/shed/cachelib_stub:cachelib",
        "//common/rust/shed/facet:facet",
        "//common/rust/shed/fbinit:fbinit",
        "//common/rust/shed/justknobs_stub:justknobs",
        "//common/rust/shed/memcache_stub:memcache",
        "//common/rust/shed/stats:stats",
        "//common/rust/zeus:zeus_client",
        "//eden/mononoke/acl_regions:acl_regions",
        "//eden/mononoke/blobstore:blobstore",
        "//eden/mononoke/blobstore:blobstore_factory",
        "//eden/mononoke/blobstore:cacheblob",
        "//eden/mononoke/blobstore:ephemeral_blobstore",
        "//eden/mononoke/blobstore:readonlyblob",
        "//eden/mononoke/blobstore:redactedblobstore",
        "//eden/mononoke/blobstore:virtually_sharded_blobstore",
        "//eden/mononoke/clients/facebook/bookmark_service_client:bookmark_service_client",
        "//eden/mononoke/clients/facebook/derived_data_service_client:derived_data_client_library",
        "//eden/mononoke/cmdlib:environment",
        "//eden/mononoke/common/futures_watchdog:futures_watchdog",
        "//eden/mononoke/common/rust/caching_ext:caching_ext",
        "//eden/mononoke/common/scuba_ext:scuba_ext",
        "//eden/mononoke/common/sql_construct:sql_construct",
        "//eden/mononoke/derived_data:derived_data_remote",
        "//eden/mononoke/features/commit_cloud:commit_cloud",
        "//eden/mononoke/features/commit_rewriting/live_commit_sync_config:live_commit_sync_config",
        "//eden/mononoke/features/commit_rewriting/synced_commit_mapping:synced_commit_mapping",
        "//eden/mononoke/features/cross_repo_sync:cross_repo_sync",
        "//eden/mononoke/features/hooks:hooks",
        "//eden/mononoke/features/repo_stats_logger:repo_stats_logger",
        "//eden/mononoke/git/bundle_uri:bundle_uri",
        "//eden/mononoke/git/git_types:git_types",
        "//eden/mononoke/megarepo_api:pushredirect",
        "//eden/mononoke/mercurial:mercurial_mutation",
        "//eden/mononoke/metaconfig:metaconfig_types",
        "//eden/mononoke/permission_checker:permission_checker",
        "//eden/mononoke/repo_attributes/bonsai_blob_mapping:bonsai_blob_mapping",
        "//eden/mononoke/repo_attributes/bonsai_git_mapping:bonsai_git_mapping",
        "//eden/mononoke/repo_attributes/bonsai_globalrev_mapping:bonsai_globalrev_mapping",
        "//eden/mononoke/repo_attributes/bonsai_hg_mapping:bonsai_hg_mapping",
        "//eden/mononoke/repo_attributes/bonsai_svnrev_mapping:bonsai_svnrev_mapping",
        "//eden/mononoke/repo_attributes/bonsai_tag_mapping:bonsai_tag_mapping",
        "//eden/mononoke/repo_attributes/bookmarks:bookmarks",
        "//eden/mononoke/repo_attributes/bookmarks/bookmarks_cache:bookmarks_cache",
        "//eden/mononoke/repo_attributes/bookmarks/dbbookmarks:dbbookmarks",
        "//eden/mononoke/repo_attributes/bookmarks/warm_bookmarks_cache:warm_bookmarks_cache",
        "//eden/mononoke/repo_attributes/commit_graph/caching_commit_graph_storage:caching_commit_graph_storage",
        "//eden/mononoke/repo_attributes/commit_graph/commit_graph:commit_graph",
        "//eden/mononoke/repo_attributes/commit_graph/commit_graph_types:commit_graph_types",
        "//eden/mononoke/repo_attributes/commit_graph/preloaded_commit_graph_storage:preloaded_commit_graph_storage",
        "//eden/mononoke/repo_attributes/commit_graph/sql_commit_graph_storage:sql_commit_graph_storage",
        "//eden/mononoke/repo_attributes/deletion_log:deletion_log",
        "//eden/mononoke/repo_attributes/filenodes:filenodes",
        "//eden/mononoke/repo_attributes/filestore:filestore",
        "//eden/mononoke/repo_attributes/git_ref_content_mapping:git_ref_content_mapping",
        "//eden/mononoke/repo_attributes/git_source_of_truth:git_source_of_truth",
        "//eden/mononoke/repo_attributes/git_symbolic_refs:git_symbolic_refs",
        "//eden/mononoke/repo_attributes/hook_manager/hook_manager:hook_manager",
        "//eden/mononoke/repo_attributes/mutable_blobstore:mutable_blobstore",
        "//eden/mononoke/repo_attributes/mutable_counters:mutable_counters",
        "//eden/mononoke/repo_attributes/mutable_renames:mutable_renames",
        "//eden/mononoke/repo_attributes/newfilenodes:newfilenodes",
        "//eden/mononoke/repo_attributes/phases:phases",
        "//eden/mononoke/repo_attributes/phases:sqlphases",
        "//eden/mononoke/repo_attributes/pushrebase_mutation_mapping:pushrebase_mutation_mapping",
        "//eden/mononoke/repo_attributes/repo_blobstore:repo_blobstore",
        "//eden/mononoke/repo_attributes/repo_bookmark_attrs:repo_bookmark_attrs",
        "//eden/mononoke/repo_attributes/repo_cross_repo:repo_cross_repo",
        "//eden/mononoke/repo_attributes/repo_derivation_queues:repo_derivation_queues",
        "//eden/mononoke/repo_attributes/repo_derivation_queues/facebook:zelos_queue",
        "//eden/mononoke/repo_attributes/repo_derived_data:repo_derived_data",
        "//eden/mononoke/repo_attributes/repo_event_publisher:repo_event_publisher",
        "//eden/mononoke/repo_attributes/repo_identity:repo_identity",
        "//eden/mononoke/repo_attributes/repo_lock:repo_lock",
        "//eden/mononoke/repo_attributes/repo_metadata_checkpoint:repo_metadata_checkpoint",
        "//eden/mononoke/repo_attributes/repo_permission_checker:repo_permission_checker",
        "//eden/mononoke/repo_attributes/repo_sparse_profiles:repo_sparse_profiles",
        "//eden/mononoke/repo_attributes/restricted_paths:restricted_paths",
        "//eden/mononoke/repo_attributes/sql_query_config:sql_query_config",
        "//eden/mononoke/repo_client:streaming_clone",
        "//eden/mononoke/server/context:context",
        "//eden/mononoke/wireproto_handler:wireproto_handler",
        "//eden/scm/lib/clientinfo:clientinfo",
    ] + ([] if rust_oss.is_oss_build() else [
        "fbsource//third-party/rust:lazy_static",
        "//eden/mononoke/facebook/ods3_schemas:MononokeRepoFactoryStats_ods3-rs_bindings",
    ]),
)

rust_library(
    name = "test_repo_factory",
    srcs = glob(["test_repo_factory/src/**/*.rs"]),
    autocargo = {"cargo_toml_dir": "test_repo_factory"},
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:maplit",
        "fbsource//third-party/rust:strum",
        "//common/rust/shed/facet:facet",
        "//common/rust/shed/fbinit:fbinit",
        "//common/rust/shed/sql:sql",
        "//eden/mononoke/acl_regions:acl_regions",
        "//eden/mononoke/blobstore:blobstore",
        "//eden/mononoke/blobstore:cacheblob",
        "//eden/mononoke/blobstore:ephemeral_blobstore",
        "//eden/mononoke/blobstore:memblob",
        "//eden/mononoke/blobstore:redactedblobstore",
        "//eden/mononoke/common/rendezvous:rendezvous",
        "//eden/mononoke/common/rust/sql_ext:sql_ext",
        "//eden/mononoke/common/scuba_ext:scuba_ext",
        "//eden/mononoke/common/sql_construct:sql_construct",
        "//eden/mononoke/features/commit_cloud:commit_cloud",
        "//eden/mononoke/features/commit_rewriting/live_commit_sync_config:live_commit_sync_config",
        "//eden/mononoke/features/commit_rewriting/synced_commit_mapping:synced_commit_mapping",
        "//eden/mononoke/features/repo_stats_logger:repo_stats_logger",
        "//eden/mononoke/git/bundle_uri:bundle_uri",
        "//eden/mononoke/git/git_types:git_types",
        "//eden/mononoke/megarepo_api:megarepo_mapping",
        "//eden/mononoke/megarepo_api:pushredirect",
        "//eden/mononoke/mercurial:mercurial_mutation",
        "//eden/mononoke/metaconfig:metaconfig_types",
        "//eden/mononoke/mononoke_types:mononoke_types",
        "//eden/mononoke/permission_checker:permission_checker",
        "//eden/mononoke/repo_attributes/bonsai_git_mapping:bonsai_git_mapping",
        "//eden/mononoke/repo_attributes/bonsai_globalrev_mapping:bonsai_globalrev_mapping",
        "//eden/mononoke/repo_attributes/bonsai_hg_mapping:bonsai_hg_mapping",
        "//eden/mononoke/repo_attributes/bonsai_svnrev_mapping:bonsai_svnrev_mapping",
        "//eden/mononoke/repo_attributes/bonsai_tag_mapping:bonsai_tag_mapping",
        "//eden/mononoke/repo_attributes/bookmarks:bookmarks",
        "//eden/mononoke/repo_attributes/bookmarks/bookmarks_cache:bookmarks_cache",
        "//eden/mononoke/repo_attributes/bookmarks/dbbookmarks:dbbookmarks",
        "//eden/mononoke/repo_attributes/bookmarks/warm_bookmarks_cache:warm_bookmarks_cache",
        "//eden/mononoke/repo_attributes/commit_graph/commit_graph:commit_graph",
        "//eden/mononoke/repo_attributes/commit_graph/sql_commit_graph_storage:sql_commit_graph_storage",
        "//eden/mononoke/repo_attributes/filenodes:filenodes",
        "//eden/mononoke/repo_attributes/filestore:filestore",
        "//eden/mononoke/repo_attributes/git_ref_content_mapping:git_ref_content_mapping",
        "//eden/mononoke/repo_attributes/git_source_of_truth:git_source_of_truth",
        "//eden/mononoke/repo_attributes/git_symbolic_refs:git_symbolic_refs",
        "//eden/mononoke/repo_attributes/hook_manager/hook_manager:hook_manager",
        "//eden/mononoke/repo_attributes/mutable_blobstore:mutable_blobstore",
        "//eden/mononoke/repo_attributes/mutable_counters:mutable_counters",
        "//eden/mononoke/repo_attributes/mutable_renames:mutable_renames",
        "//eden/mononoke/repo_attributes/newfilenodes:newfilenodes",
        "//eden/mononoke/repo_attributes/phases:phases",
        "//eden/mononoke/repo_attributes/phases:sqlphases",
        "//eden/mononoke/repo_attributes/pushrebase_mutation_mapping:pushrebase_mutation_mapping",
        "//eden/mononoke/repo_attributes/repo_blobstore:repo_blobstore",
        "//eden/mononoke/repo_attributes/repo_bookmark_attrs:repo_bookmark_attrs",
        "//eden/mononoke/repo_attributes/repo_cross_repo:repo_cross_repo",
        "//eden/mononoke/repo_attributes/repo_derived_data:repo_derived_data",
        "//eden/mononoke/repo_attributes/repo_event_publisher:repo_event_publisher",
        "//eden/mononoke/repo_attributes/repo_identity:repo_identity",
        "//eden/mononoke/repo_attributes/repo_lock:repo_lock",
        "//eden/mononoke/repo_attributes/repo_metadata_checkpoint:repo_metadata_checkpoint",
        "//eden/mononoke/repo_attributes/repo_permission_checker:repo_permission_checker",
        "//eden/mononoke/repo_attributes/repo_sparse_profiles:repo_sparse_profiles",
        "//eden/mononoke/repo_attributes/restricted_paths:restricted_paths",
        "//eden/mononoke/repo_attributes/sql_query_config:sql_query_config",
        "//eden/mononoke/repo_client:streaming_clone",
        "//eden/mononoke/server/context:context",
        "//eden/mononoke/wireproto_handler:wireproto_handler",
    ],
)

rust_library(
    name = "config_only_repo_factory",
    srcs = glob(["config_only_repo_factory/src/**/*.rs"]),
    autocargo = {"cargo_toml_dir": "config_only_repo_factory"},
    deps = [
        "//common/rust/shed/facet:facet",
        "//eden/mononoke/blobstore:blobstore_factory",
        "//eden/mononoke/metaconfig:metaconfig_types",
        "//eden/mononoke/repo_attributes/repo_identity:repo_identity",
    ],
)
